#!/usr/bin/env python 

#############################################################
# Installation script for standalone installation
# of DCOracle 2 
# 
# Requirements: Python 1.X, 2.X
# Python DistUtils
#
# Digital Creations
# Andreas Jung (andreas@digicool.com) 03/24/2001
#
# tested platforms:
# - Linux i386 
#
# tested Oracle versions:
# - Oracle 8.1.5, 8.1.7 (Linux)
#############################################################


from distutils.core import setup,Extension 
import os,exceptions,string,commands,sys


OH = os.environ.get("ORACLE_HOME",None)
if OH==None: raise exceptions.RuntimeError,"$ORACLE_HOME is not set "

st,outp=commands.getstatusoutput('ldd %s' % sys.executable)
if string.find(outp,'libpth.so')!=-1:
    raise exceptions.RuntimeError,'Python interpreter is linked against -lpth. But Python must be linked against -lpthread'



st,outp=commands.getstatusoutput('ldd %s' % sys.executable)
if string.find(outp,'libpthread')==-1:
    raise exceptions.RuntimeError,'Python must be linked against -lpthread'



INCL_DIR= map(lambda x: os.path.join(OH,x) , ["rdbms/demo","network/public","plsql/public","rdbms/public"])
LIB_DIR = map(lambda x: os.path.join(OH,x) , ["lib"])

CFLAGS = ["-fPIC","-DORACLE8i"]
LFLAGS = ["-Wl,-rpath,%s" % string.join(LIB_DIR,",")]

LIBS=['clntsh']


setup (name = "DCOracle2",
       version = "1.0",
       description = "DCOracle2 - Python bindings for Oracle 8i",
       author = "Matt Kromer",
       author_email = "matt@digicool.com",
       url = "http://www.zope.org/Members/...",        
       packages = ['DCOracle2'],
       ext_modules=[Extension("dco2",['src/dco2.c'], \
                    include_dirs=INCL_DIR, \
                    library_dirs=LIB_DIR, \
                    libraries=LIBS ,
                    extra_compile_args=CFLAGS,
                    extra_link_args=LFLAGS,
                   )]

      )
